<!--
  - AddAnalysisLib.php
  - v0.01
  - 2/1/2011
  -
  -	This inserts an analysis into the database.
-->
<?php
	function InsertNewSampleDetail($name,$company,$address,$fax,$telno,$email,
			$cell, $prepared_by, $database, $host,
			$login,$loginpassword, $tablename){ 
		//Create connection. 
		$connect = 
				mysql_connect($host,$login,$loginpassword);	
		if (!$connect) {
			die('Could not connect: ' . mysql_error());
		}
		
		//Set-up and execute query.		
		mysql_select_db($database, $connect);		
		$query = "INSERT INTO $tablename (name, company, address, fax, tel_no, email, cell_no, prepared_by)	
				VALUES ('$name', '$company', '$address', '$fax', '$telno', '$email', '$cell', '$prepared_by')";
		$analysis = mysql_query($query);
			
		if ($analysis == true) {
			$query = "SELECT LAST_INSERT_ID()";
			$newidref = mysql_query($query);
			$newid = mysql_fetch_array($newidref);
		}
		//Close connection.
		mysql_close($connect);				
		if ($analysis == true) {
			return $newid[0];
		} else {
			return FALSE;
		}
		
	}
?>